package com.sd.repay.service.impl;

import com.sd.repay.dao.BaseDao;
import com.sd.repay.pojo.TransferOrder;
import com.sd.repay.service.TransferOrderService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author sd
 * @Description: 平台出款服务类
 * @date 2017年10月25日
 */
@Service
public class TransferOrderServiceImpl implements TransferOrderService {

    private static Logger log = LoggerFactory.getLogger(TransferOrderServiceImpl.class);

    @Autowired
    private BaseDao baseDao;

    /**
     * 根据来源订单号获取平台出款记录
     *
     * @param sourceOrderNo
     * @param orderType
     * @return
     * @throws Exception
     */
    @Override
    public TransferOrder getTransferOrderBySource(String sourceOrderNo, String orderType) throws Exception {

        String sql = " SELECT * FROM t_transfer_order WHERE source_order_no = ? AND order_type = ?";
        return baseDao.findFirst(TransferOrder.class, sql, new Object[]{sourceOrderNo, orderType});
    }

    /**
     * 根局提交订单号获取平台出款记录
     *
     * @param submitOrderNo
     * @return
     * @throws Exception
     */
    @Override
    public TransferOrder getTransferOrderBySubmitOrderNo(String submitOrderNo) throws Exception {

        String sql = " SELECT * FROM t_transfer_order WHERE submit_order_no = ? ";
        return baseDao.findFirst(TransferOrder.class, sql, submitOrderNo);
    }

    /**
     * 根据订单号获取平台出款记录
     *
     * @param orderNo
     * @return
     * @throws Exception
     */
    @Override
    public TransferOrder getTransferOrderByOrderNo(String orderNo) throws Exception {

        String sql = " SELECT * FROM t_transfer_order WHERE order_no = ? ";
        return baseDao.findFirst(TransferOrder.class, sql, orderNo);
    }
}